<include file="Public/head" />
<script src="{:get_style_cdnurl()}paimai/yunying/js/city.js"></script>
<style>
    #fail_type {
        -moz-appearance: none;
        background: rgba(0, 0, 0, 0) url("http://img1.isou365.cn/paimai/yunying/images/sanjiao.jpg") no-repeat scroll 130px 5px;
        border: 1px solid #d7d7d7;color: #666;float: left; height: 25px;line-height: 25px;margin-left: 24px;margin-right: 10px;text-align: center;width: 150px;}
    #searchFrom .sheng-text{height:26px;width:100px;background:url("http://img3.isou365.cn/paimai/yunying/images/sanjiao.jpg") no-repeat scroll 80px 7px;border:solid 1px #c5c5c5;margin-right:7px;}
    #searchFrom .area{margin:0;}
    #searchFrom #area{width:140px; background-position:120px 7px}
    </style>
</head>
<include file="Public/common_header" />
<div class="mian">
    <include file="Public/sidebar" menu="cljc.jcdd"/>
    <div class="mianR">
        <div class="yuyue">
            <ul>
                <li onclick="window.location.href = '/DetectScheduling/index'">待分配</li>
                <li onclick="window.location.href = '/DetectScheduling/detect'">待检测</li>                    
                <li onclick="window.location.href = '/DetectScheduling/success'">检测成功</li>                    
                <li onclick="window.location.href = '/DetectScheduling/fail'">检测失败</li>
                <li onclick="window.location.href = '/DetectScheduling/retention'"  class="yuCurrent">滞留</li>
            </ul>
        </div>
        <form id="searchFrom">
        <div class="yuSuo clearfix">

                <input id="status" name="status" type="hidden" value="9"/>
                <span>按预约时间筛选：</span>
                <input type="text" id="start_time" name="start_time" value="{$params.reserve_start_time}" readonly placeholder="请选择预约时间" />
                <em></em>
                <input type="text" id="end_time" name="end_time" value="{$params.reserve_end_time}" readonly placeholder="请选择预约时间" style="margin-right: 10px;"/>
                <select id="location_area" name="location_area" class="branch_company">
                    <if condition="count($bc_city) gt 1">
                        <option value="">请选择所在地</option>
                    </if>
                    <volist name="bc_city" id="city">
                        <option value="{$key}">{$city}</option>
                    </volist>
                </select>
                <input type="text" id="owner_id" name="owner_id" placeholder="车主ID" value="{$params.owner_id}" class="suoDian" />
        </div>
        <div class="yuSuo clearfix">
                <span>预约地址：</span>
                 <div class="area">
                    <select id="province" name="province"  class="sheng-text">
                        <option value="省份">省份</option>
                    </select>
                    <select id="city"  name="city" class="sheng-text">
                        <option>地级市</option>
                    </select>
                    <select id="area"  name="area" class="sheng-text">
                        <option>市、区、县</option>
                    </select>
                </div>
            <input type="button" onclick="fnSearch();" id="search" value="搜索" class="suoSou">
        </div>
        </form>
        <div class="listBox" id="listBox">

        </div>
        <div class="clear"></div>
        <!--再预约弹出窗口-->
        <div class="yunBei" style="display:none"></div>
        <form id="add_fm">
            <div class="tanShang tanShang6" style="display:none">
                <h3>再预约信息</h3>
                <ul class="daiJingW">
                    <li class="clearfix">
                        <textarea name="reserve_remark" id="reserve_remark" placeholder="请输入需要预约的时间和其他信息" style="resize:none;width:450px;height:80px;border:1px solid #ececec;"></textarea>
                    </li>
                    <li class="clearfix">
                        <input type="hidden" name="owner_id">
                        <input type="button" value="确定" class="queding"/>          
                        <input type="button" value="取消" class="quxiao" />          
                    </li>
                </ul>
            </div>
        </form>
    </div>
</div>
</body>
<script type="text/javascript">
    get_list();
    function get_list() {
        $.get("/DetectScheduling/retention_list", {"status": '9'}, function (data) {
            $("#listBox").html(data);
        }, "html");
    }

    function get_page(p) {
        var data = $("#searchFrom").serialize() + "&" + encodeURI("p=" + p);
        $.get("/DetectScheduling/retention_list", data, function (data) {
            $("#listBox").html(data);
        }, "html");
    }

    function fnSearch() {
        $.get("/DetectScheduling/retention_list", $("#searchFrom").serialize(), function (data) {
            $("#listBox").html(data);
        }, "html");
    }
    /**
     * 再分配
     * @param int owner_id
     */
    function distribute_again(owner_id) {
        var params = {
            'owner_id':owner_id
        }
        $.post("/DetectScheduling/distributeAgain", params, function (data) {
            if (data.code != 200) {
                shibai_alert(data.msg);
                return false;
            }
            setTimeout("window.location.href='/DetectScheduling/distribute_again?id=" + owner_id + "&again=1'", 500);
        }, "json");
    }

    /**
     * 再预约
     * @param int owner_id
     */
    function reserve_again(owner_id) {

        $.post("/DetectScheduling/reserveIng", {'owner_id':owner_id}, function (data) {
             if (data.code != 200) {
                shibai_alert(data.msg);
                return false;
              }
            $('.add_fm,.tanShang6').show();
            $("input[name='owner_id']").val(owner_id);
        },'json');
    }
    /**
     * 提交再预约信息
     */
    $('.queding').click(function (data) {
        var owner_id = $("input[name='owner_id']").val();
        var remark = $("#reserve_remark").val();
        var params = {
            'owner_id': owner_id,
            'remark': remark
        }
        $.post("/DetectScheduling/reserveAgain", params, function (data) {
            if (data.code != 200) {
                shibai_alert(data.msg);
                return false;
            }
            btn_alert(data.msg);
            setTimeout("window.location.href='/DetectScheduling/retention'", 1500);
        }, "json");
    });
    /**
     * 获取省市区
     */
    function area() {
        $.ajax({
            type: "GET",
            url: "http://www.lpaiche.com/Index/address?level=0",
            dataType: "jsonp",
            success: function (res) {
                $.each(res.data, function (i, item) {
                    $("#province").append("<option value='" + item.city_code + "'>" + item.city_name + "</option>");
                })
            }
        })

        $("#province").change(function () {
            $("#city").html("");
            $("#area").html("");
            if ($(this).find("option:selected").text() == "北京" || $(this).find("option:selected").text() == "上海" || $(this).find("option:selected").text() == "重庆" || $(this).find("option:selected").text() == "天津") {
            } else {
                $("#city").append("<option value='地级市'>地级市</option>")
            }
            if ($("#province").val() == "省份") {
                $("#city").append("<option value='地级市'>地级市</option>")
                $("#area").append("<option value='市、县、区'>市、县、区</option>")
            }
            $.ajax({
                type: "GET",
                url: "http://www.lpaiche.com/Index/address?pid=" + $(this).val(),
                cache: true,
                dataType: "jsonp",
                success: function (res) {
                    var n = null;
                    $.each(res.data, function (i, item) {
                        $("#city").append("<option value='" + item.city_code + "'>" + item.city_name + "</option>");
                        //n=i;
                    });
                    if (n == 1) {
                        $("#city").change();
                    }
                    if (n <= $("#city option").length) {
                        $("#city").change();
                    }
                    if ($("#city option").length == 1) {
                        $("#city").hide();
                    } else {
                        $("#city").show();
                    }



                }
            })
        })
        $("#city").change(function () {

            $("#area").html("");
            $("#area").append("<option value='市、县、区'>市、县、区</option>");
            if ($("#city").val() == "地级市") {
                $("#area").append("<option value='市、县、区'>市、县、区</option>")
            }
            //  $("#area").append("<option value='市、县、区'>市、县、区</option>")
            //$('#area').append(title[2]);
            $.ajax({
                type: "GET",
                cache: true,
                //json文件位置  
                url: "http://www.lpaiche.com/Index/address?pid=" + $(this).val(),
                //返回数据格式为json  
                dataType: "jsonp",
                //请求成功完成后要执行的方法  
                success: function (res) {
                    //使用$.each方法遍历返回的数据date,插入到id为#result中  
                    //$("#area").html("");
                    $.each(res.data, function (i, item) {

                        $("#area").append("<option value='" + item.city_code + "'>" + item.city_name + "</option>")
                    })

                }
            })


        })

    }
    $(function () {
        area();
        $("select").css("color", "#303030");
        $("select").find("option").css("color", "#303030");
        $("select").each(function () {
            $(this).change(function () {
                var selectIndex = $(this).get(0).selectedIndex;
                if (selectIndex == 0) {
                    $(this).css("color", "#303030");
                    $("#comeFrom").css("color", "#303030");
                    $(this).find("option").css("color", "#303030");
                } else {
                    $(this).css("color", "#303030");
                }
            })
        });
    })

</script>
</html>